class HandlerManager
   def initialize
      @handler = {} 
      @default = nil
   end   

   def add_handler(name, handler)
      if !@handler.has_key?(name)
         @handler[name] = handler
      else
         raise "Handler #{name} allready present"
      end
   end

   def get_handler_by_name(name)
      @handler[name]
   end

   def set_handler_by_name(name)
      if @handler.has_key?(name)
         @default = name
      else
         raise "No such handler #{name}"
      end
   end

   def get_default_handler
       if @default
          @handler[@default]
       else
           raise "No handler set"
       end
   end

   def run
     begin
       get_default_handler.run
     rescue Pcap::PcapError => e
       pp e
       exit -1
     end
   end

   def get_default_bars
      get_default_handler.get_default_bars 
   end
end
